<?php


namespace app\admin\controller;


use app\admin\library\Auth;
use app\admin\model\Announcement;
use app\BaseController;
use app\middleware\CheckLogin;
use think\facade\Db;
use think\facade\Session;
use think\facade\View;
use think\Hook;

class Index extends BaseController
{


    public function initialize()
    {
        parent::initialize();
        View::assign('id',$this->auth->id);
        View::assign('username',$this->auth->nickname);
        View::assign('avatar',$this->auth->portrait);
        View::assign('sign',"在深邃的编码世界，做一枚轻盈的纸飞机");
    }

    public function index()
    {

        $this->auth = Auth::instance();
        $where[] = array("status", "=", 0);
        $where[] = array("receiveid", "=", $this->auth->id);
        $total = Db::name('view_workitem')
            ->where($where)
            ->count();
        list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
            'dashboard' => 'hot',
            'addon' => ['new', 'red', 'badge'],
            'auth/rule' => ('Menu'),
            'general' => ['new', 'purple'],
        ]);
        $menu = toChildrenPid($menulist);
        View::assign('total', $total);
        View::assign('menu', $menu);

        return View::fetch();
    }

    public function console()
    {
        return View::fetch();
    }
}